package graphics.raytracing;

import static util.MatrixOperationsF.ar;
import static util.MatrixOperationsF.cloo;
import static util.MatrixOperationsF.multiply;
import static util.MatrixOperationsF.normalize;
import graphics.datastructures.Model;

public class SimpleRay implements Ray {
	private float[] _origin;
	private int _num;
	public final float[] _direction;
	private LightSource _source;
	private int[] _xy;
	private RayRunner _runner;

	public SimpleRay(float[] origin, float[] direction, int num,
			LightSource source,int[] xy) {
		_direction = cloo(direction);
		_origin = cloo(origin);
		_num = num;
		_source = source;
		_xy=xy;
	}


	@Override
	public boolean canBeCast() {
		return _num > 0;
	}
	
	@Override
	public void makeRay(final Model trace, final Window window) {
		Runnable rv = new Runnable() {
			
			@Override
			public void run() {
				CastResult result = trace.cast(SimpleRay.this);
				window.color(_xy,result);
				}
		};
		_runner.registerRay(rv);
	}

	@Override
	public float[] getOrigin() {
		return _origin;
	}

	@Override
	public float[] getDirection() {
		return _direction;
	}

	@Override
	public Ray setRunner(RayRunner runner)
	{
		_runner=runner;
		return this;
	}


}
